package newpackage;

import java.security.*;
import java.math.*;

public class NewClass {

    public static void main(String[] args) {
        String string = "prf6351"+"ScY9ykxvs6u7VFjkka6m";
        System.out.println("MD5: "+ md5(string));

        
        MessageDigest m;

        try {
            m = MessageDigest.getInstance("MD5");
            m.update(string.getBytes(), 0, string.length());
            BigInteger i = new BigInteger(1, m.digest());

            //Formatando o resuldado em uma cadeia de 32 caracteres, completando com 0 caso falte 
            string = String.format("%1$032X", i);

            System.out.println("MD5: " + string);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } 
    }
    
        //Função para criar hash da senha informada  
    public static String md5(String senha){  
        String sen = "";  
        MessageDigest md = null;  
        try {  
            md = MessageDigest.getInstance("MD5");  
        } catch (NoSuchAlgorithmException e) {  
            e.printStackTrace();  
        }  
        BigInteger hash = new BigInteger(1, md.digest(senha.getBytes()));  
        sen = hash.toString(16);              
        return sen;  
    } 
}


